package net.mysoft.budgetsoft.system.action;

import javax.annotation.Resource;

import net.mysoft.budgetsoft.system.pagemodel.JueSe;
import net.mysoft.budgetsoft.system.service.JueSeService;
import net.mysoft.framework.authority.AccessType;
import net.mysoft.framework.authority.Permission;
import net.mysoft.framework.base.BaseAction;
import net.mysoft.framework.model.Json;
import net.mysoft.framework.util.ExceptionUtil;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ModelDriven;

/**   
 *  
 * @author dagongPGP v1.0 
 * @link <a href=http://www.dagongsoft.net>北京大公信软科技有限公司</a> 
 *  
 * @version $Revision: 1.00  $Date: 2013-12-27 14:09:49 
 */
@Action(value = "jueSeAction", results = { 
		@Result(name = "jueSe", location = "/platform/system/jueSe.jsp"), 
		@Result(name = "jueSeAdd", location = "/platform/system/jueSeAdd.jsp"), 
		@Result(name = "jueSeEdit", location = "/platform/system/jueSeEdit.jsp"), 
		@Result(name = "jueSeView", location = "/platform/system/jueSeView.jsp"),
		@Result(name = "jueSeSelect", location = "/platform/system/jueSeSelect.jsp")})
@Controller("jueSeAction")
public class JueSeAction extends BaseAction implements ModelDriven<JueSe>{

	private static final Logger logger = Logger.getLogger(JueSeAction.class);
	@Resource
	private JueSeService jueSeService;
	
	private JueSe jueSe = new JueSe();
	
	public JueSeService getJueSeService(){
		return this.jueSeService;
	}
	
	public void setJueSeService(JueSeService jueSeService){
		this.jueSeService = jueSeService;
	}
	
	public JueSe getJueSe(){
		return this.jueSe;
	}
	
	public void setJueSe(JueSe jueSe){
		this.jueSe = jueSe;
	}
	
	public JueSe getModel() {
		return jueSe;
	}
	
	/**
	 * JueSe列表页面
	 * @return
	 */
	public String jueSe() {
		return "jueSe";
	}
	
	/**
	 * JueSe查看页面
	 * @return
	 */
	public String jueSeView() {
		return "jueSeView";
	}
	
	/**
	 * JueSe添加页面
	 * @return
	 */
	public String jueSeAdd() {
		return "jueSeAdd";
	}
	
	/**
	 * JueSe编辑页面
	 * @return
	 */
	public String jueSeEdit() {
		return "jueSeEdit";
	}
	/**
	 * JueSe选择页面
	 * @return
	 */
	@Permission(access=AccessType.LOGIN)
	public String jueSeSelect() {
		return "jueSeSelect";
	}
	/**
	 * 添加
	 */
	@Permission(access=AccessType.LOGIN)
	public void add() {
		Json j = new Json();
		try {
			//SessionInfo sessionInfo = (SessionInfo) this.getSession().getAttribute(ResourceUtil.getSessionInfoName());
			jueSeService.add(jueSe);
			j.setSuccess(true);
			j.setMsg("添加成功!");
		} catch (Exception e) {
			logger.error(ExceptionUtil.getExceptionMessage(e));
			j.setMsg("添加失败！");
		}
		super.writeJson(j);
	}
	
	/**
	 * 修改
	 */
	@Permission(access=AccessType.LOGIN)
	public void edit() {
		Json j = new Json();
		try {
			jueSeService.edit(jueSe);
			j.setSuccess(true);
			j.setMsg("编辑成功!");
		} catch (Exception e) {
			logger.error(ExceptionUtil.getExceptionMessage(e));
			j.setMsg("编辑失败！");
		}
		super.writeJson(j);
	}
	
	/**
	 * 删除
	 */
	@Permission(access=AccessType.LOGIN)
	public void delete() {
		Json j = new Json();
		try {
			jueSeService.delete(jueSe);
			j.setSuccess(true);
			j.setMsg("删除成功！");
		} catch (Exception e) {
			logger.error(ExceptionUtil.getExceptionMessage(e));
			j.setMsg("删除失败！");
		}
		super.writeJson(j);
	}
	
	/**
	 * 列表
	 */
	public void datagrid() {
		try {
			super.writeJson(jueSeService.datagrid(jueSe));
		} catch (Exception e) {
			logger.error(ExceptionUtil.getExceptionMessage(e));
		}
	}
	
	/**
	 * 下拉框
	 */
	@Permission(access=AccessType.LOGIN)
	public void combobox(){
		super.writeJson(jueSeService.combobox());
	}
	
	/**
	 * 下拉框
	 */
	@Permission(access=AccessType.LOGIN)
	public void check(){
		super.writeJson(jueSeService.check(jueSe));
	}
}
